package com.tiancheng.trade.payment.enums;

import com.tiancheng.trade.commom.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 渠道退款类型
 *
 * @Date 2024/11/5
 * @Author DCH
 */
@Getter
@AllArgsConstructor
public enum ChannelRefundTypeEnum implements BaseEnum<Integer> {
    ALL(0, "整单退款"),
    SPLIT(1, "部分退款"),
    ;
    private Integer code;
    private String desc;

    public static String getDesc(int code) {
        Optional<ChannelRefundTypeEnum> found = Arrays.stream(ChannelRefundTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
